import scrapy


class Zongheng1Spider(scrapy.Spider):
    name = "zongheng1"

    # start_urls = ["https://www.zongheng.com/api2/catefine/storeSearch"]

    async def start(self):


        for page in range(1, 2):
            yield scrapy.FormRequest(url='https://www.zongheng.com/api2/catefine/storeSearch', headers = {
                'referer': 'https://www.zongheng.com/books?worksTypes=0&subWorksTypes=0&totalWord=0&serialStatus=1&vip=9&bookType=0',
                'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36'

            },formdata={
                "worksTypes": '0',
                "bookType": '0',
                "subWorksTypes": '0',
                "totalWord": '0',
                "serialStatus": '1',
                "vip": '9',
                "pageNum": f'{page}',
                "pageSize": '20',
                "categoryId": '0',
                "categoryPid": '0',
                "order": "weekOrder",
                "naodongFilter": '0'
            })

    async def parse(self, response):
        print(response.json())
        # bookId = response.json()['result']['bookList']['bookId']
        # title = response.json()['result']['bookList']['name']

        # print(bookId, title)
